﻿@model IEnumerable<HelpDesk.Models.Ticket>

@{
    ViewBag.Title = "All Tickets";
}
<link href="~/Content/DataTabblesBs.css" rel="stylesheet" />

@section Scripts {
    <script src="~/Scripts/jquery.dataTables.min.js"></script>
    <script src="~/Scripts/DataTablesBS.js"></script>
    <script>
        $(document).ready(function () {
            $('#Tickets').dataTable({
                "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
                "sWrapper": "dataTables_wrapper form-inline"
            });
        });

    </script>
}
<div class="span12">
    <div class="well">
        <a href="@Url.Action("CreateTicket", "Ticket")" class="btn btn-primary"><i class="icon-plus"></i>Create New Ticket</a>
    </div>

    <table id="Tickets" class="table table-striped table-hover">
        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.TicketID)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Title)
                </th>
                @*<th>
                    @Html.DisplayNameFor(model => model.Description)
                </th>*@
                <th>
                    @Html.DisplayNameFor(model => model.Created)
                </th>
                <th>Submitted By
                </th>
                <th>Assigned To
                </th>
                <th>Priority
                </th>
                <th>Status
                </th>
                <th></th>
            </tr>
        </thead>
        <tbody class=":nth-child">
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        <a title="View Ticket Details" href="@Url.Action("Details", "Ticket", new { id = item.TicketID })">@Html.DisplayFor(modelItem => item.TicketID)</a>
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Title)
                    </td>
                    @* <td>
                        @Html.DisplayFor(modelItem => item.Description)
                    </td>*@
                    <td>
                        @Html.DisplayFor(modelItem => item.Created)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Customer.FirstName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.SupportStaff.FirstName)
                    </td>
                    <td><span class="label @item.Priority.Color">@item.Priority.Priority</span></td>
                    <td><span class="label @item.Status.Color">@item.Status.Status</span></td>
                    <td>
                        <span class="btn-toolbar">
                            <span class="btn-group">
                                <a rel="tooltip" data-placement="top" data-original-title="View Ticket Details" class="btn btn-info" href="@Url.Action("Details", "Ticket", new { id = item.TicketID })"><i class="icon-info-sign"></i></a>
                                @if (@item.Status.Status.ToLower() != "closed")
                                {
                                    <a class="btn @(@item.Status.Status.ToLower() == "closed" ? "disabled" : "btn-danger")" data-modal-Text="Are you sure you want to close ticket# @item.TicketID?" data-modal-show-footer="true" data-modal-header="Close Ticket" data-modal-url-action="@Url.Action("CloseTicket", "Ticket", new { id = @item.TicketID })"><i class="icon-refresh"></i></a>
                                }
                                else
                                {
                                    <a class="btn disabled"><i class="icon-refresh"></i></a>
                                }
                            </span>
                        </span>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>
@Html.Partial("_ModalBox")
